﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:v="clr-namespace:NtpChat.Client"
		xmlns:vm="clr-namespace:NtpChat.Client.ViewModel" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="NtpChat.Client.MainWindow"
        Title="MainWindow"
        Height="431"
        Width="300"
		Name="MainView"
		
        Background="#FFEDEDED" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Loaded="MainView_Loaded">
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
			<vm:ColorConverter x:Key="colorConverter"/>
			<DataTemplate x:Key="friendsTemplate">
				<Border MinWidth="100" BorderThickness="0,0,0,1" BorderBrush="#FF212121" Background="{x:Null}" >
					<DockPanel LastChildFill="False" Height="21.28">
						<Border BorderBrush="#FF353131" BorderThickness="1" Width="15" Height="15" Margin="5,0,0,0" CornerRadius="3">
							<Border.Effect>
								<DropShadowEffect Direction="291" BlurRadius="6" ShadowDepth="2"/>
							</Border.Effect>
							<Border.Background>
								<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
									<GradientStop Color="{Binding Status, Converter={StaticResource colorConverter}}" Offset="0.57"/>
									<GradientStop Color="Silver" Offset="1"/>
								</LinearGradientBrush>
							</Border.Background>
						</Border>
						<TextBlock TextWrapping="Wrap" Text="{Binding UserName}" VerticalAlignment="Center" Padding="10,0,0,0" FontSize="16" Margin="0,0,5,0">
							<TextBlock.InputBindings>
													<MouseBinding MouseAction="LeftClick" Command="{Binding OpenConversationCommand}" CommandParameter="{Binding ElementName = friendsList, Path=SelectedItem}" CommandTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext}" ></MouseBinding>
							</TextBlock.InputBindings>
						</TextBlock>
					</DockPanel>

				</Border>
			
			</DataTemplate>
        	<DataTemplate DataType="{x:Type vm:UserViewModel}">
        		<Border MinWidth="284" MinHeight="50" MaxWidth="Infinity" BorderThickness="1" CornerRadius="6" BorderBrush="#FFADADAD" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MaxHeight="100" Margin="0" Padding="0">
        			<Border.Background>
        				<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
        					<GradientStop Color="{Binding Status, Converter={StaticResource colorConverter}}" Offset="0.57"/>
        					<GradientStop Color="Silver" Offset="1"/>
        				</LinearGradientBrush>
        			</Border.Background>
        			<DockPanel HorizontalAlignment="Stretch">
        				<Image Width="40" Height="40"/>
        				<TextBlock TextWrapping="Wrap" Text="{Binding UserName}" DockPanel.Dock="Right" Margin="5" TextAlignment="Left" FontSize="21.333" VerticalAlignment="Center" Foreground="White"/>
        			</DockPanel>
        		</Border>
        	</DataTemplate>
			
        	<DataTemplate DataType="{x:Type vm:LoginViewModel}">
        		<v:LoginView/>
        	</DataTemplate>
        </ResourceDictionary>
		
    </Window.Resources>

	<Window.DataContext>
		<Binding Path="Main" Source="{StaticResource Locator}"/>
	</Window.DataContext>

    <DockPanel x:Name="LayoutRoot">
		<StackPanel DockPanel.Dock="Top">
			<ContentControl Content="{Binding TopVM}" MaxHeight="50" MinHeight="50" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"/>
		</StackPanel>
		<StackPanel>
			<DockPanel Width="284">
				<ListBox x:Name="friendsList" DockPanel.Dock="Top" Background="#FFEDEDED" BorderBrush="{x:Null}" BorderThickness="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" MinHeight="295" ItemsSource="{Binding Friends}" ItemTemplate="{StaticResource friendsTemplate}"/>
				<Button Content="Chat" Width="75" VerticalAlignment="Top" DockPanel.Dock="Bottom" Margin="0,0,5,0" HorizontalAlignment="Right" Command="{Binding OpenConversationCommand}" CommandParameter="{Binding SelectedItem, ElementName=friendsList}"/>
			</DockPanel>
			<Button Content="Button" Command="{Binding StartRecordingCommand}" Width="100" HorizontalAlignment="Left" d:LayoutOverrides="Height"/>
		</StackPanel>
	</DockPanel>
</Window>
